{{define "system/post/add"}}
<!DOCTYPE html>
<html lang="zh">
<head>
    {{template "header" (OssUrl)}}
</head>
<body class="white-bg">
<div class="wrapper wrapper-content   ibox-content">
    <form class="form-horizontal m" id="form-post-add">
        <div class="form-group">
            <label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">岗位名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="postName" id="postName" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label ">岗位编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="postCode" id="postCode" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">显示顺序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="postSort" id="postSort" value="100">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">岗位状态：</label>
            <div class="col-sm-8">
				{{DictRadio "sys_normal_disable" "status" ""}}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 col-md-4 col-lg-4 col-xl-4 control-label control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
{{template "footer" (OssUrl)}}
<script type="text/javascript">
    var prefix = ctx + "/system/post";
    // 远程验证，接口必须返回 "true" 或 "false",返回false时会显示错误信息
    $("#form-post-add").validate({
        onkeyup: false,
        rules: {
            postCode: {
                remote: {
                    url: ctx + "/system/post/isPostCodeExist",
                    type: "post",
                    dataType: "json",
                    data: {
                        "postCode": function () {
                            return $.common.trim($("#postCode").val());
                        }
                    },
                    dataFilter: function(response) {
                        let json = $.parseJSON(response);
                        let exist = json.data
                        if (exist) { // 不能过
                            return  "\"" + json.msg + "\"";
                        }
                        return true; //通过
                    }
                }
            },
            postSort: {
                digits: true
            },
        },
        // messages: {
        //     "postCode": {
        //         remote: "岗位编码已经存在"
        //     },
        // },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-post-add').serialize());
        }
    }
</script>
</body>
</html>
{{end}}